#pragma once

#include "IHttpRequest.h"

namespace Poco
{
	namespace Net
	{
		class HTTPServerRequest;
	};
};

namespace MiniHttpServer {
	ref class HttpRequest : public IHttpRequest
	{
	public:
		HttpRequest(Poco::Net::HTTPServerRequest& request);
		virtual ~HttpRequest();
		!HttpRequest();

		virtual property System::String^ RawUri { System::String^ get() override { return m_rawuri; }; };
		virtual property System::Uri^ Uri { System::Uri^ get() override { return m_uri;	}; };
		virtual property System::String^ Method { System::String^ get()  override{ return m_method; }; };
		virtual property System::Collections::Specialized::NameValueCollection^ Headers { System::Collections::Specialized::NameValueCollection^ get()  override{ return m_headers; }; };
		virtual property System::String^ ContentType { System::String^ get()  override{ return m_contentType; }; };
		virtual property __int64 ContentLength { __int64 get()  override{ return m_contentLength; }; };
		virtual property System::String^ UserAgent { System::String^ get()  override{ return m_userAgent; };	};
		virtual property bool KeepAlive { bool get()  override { return m_keepAlive; }; };
		virtual property bool HasBody { bool get() override { return GetHasBody(); }; };
		virtual System::IO::Stream^ GetBody() override { return m_requestStream; };

	private:
		bool GetHasBody();
		Poco::Net::HTTPServerRequest& m_request;
		System::String^ m_rawuri;
		System::Uri^ m_uri;
		System::String^ m_method;
		System::String^ m_contentType;
		__int64 m_contentLength;
		System::String^ m_userAgent;
		bool m_keepAlive;
		System::IO::Stream^ m_requestStream;
		System::Collections::Specialized::NameValueCollection^ m_headers;
	};
};